home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / sndhrdw / gorf.c < prev    next >
C/C++ Source or Header  |  2000-04-23  |  8KB  |  219 lines

  1. /**************************************************************************
  2.  
  3.     Gorf/Votrax SC-01 Emulator
  4.  
  5.      Mike@Dissfulfils.co.uk
  6.  
  7.         Modified to match phonemes to words
  8.  
  9.         Ajudd@quantime.co.uk
  10.  
  11. **************************************************************************
  12.  
  13. gorf_sh_start  - Start emulation, load samples from Votrax subdirectory
  14. gorf_sh_w      - Write data to votrax port
  15. gorf_sh_status - Return busy status (-1 = busy)
  16. gorf_port_2_r  - Returns status of voice port
  17. gorf_sh_ update- Null
  18.  
  19. If you need to alter the base frequency (i.e. Qbert) then just alter
  20. the variable GorfBaseFrequency, this is defaulted to 8000
  21.  
  22. **************************************************************************/
  23.  
  24. #include "driver.h"
  25. #include "cpu/z80/z80.h"
  26.  
  27.  
  28.  
  29. int    GorfBaseFrequency;        /* Some games (Qbert) change this */
  30. int     GorfBaseVolume;
  31. int     GorfChannel = 0;
  32. struct  GameSamples *GorfSamples;
  33.  
  34. /****************************************************************************
  35.  * 64 Phonemes - currently 1 sample per phoneme, will be combined sometime!
  36.  ****************************************************************************/
  37.  
  38. static const char *PhonemeTable[65] =
  39. {
  40.  "EH3","EH2","EH1","PA0","DT" ,"A1" ,"A2" ,"ZH",
  41.  "AH2","I3" ,"I2" ,"I1" ,"M"  ,"N"  ,"B"  ,"V",
  42.  "CH" ,"SH" ,"Z"  ,"AW1","NG" ,"AH1","OO1","OO",
  43.  "L"  ,"K"  ,"J"  ,"H"  ,"G"  ,"F"  ,"D"  ,"S",
  44.  "A"  ,"AY" ,"Y1" ,"UH3","AH" ,"P"  ,"O"  ,"I",
  45.  "U"  ,"Y"  ,"T"  ,"R"  ,"E"  ,"W"  ,"AE" ,"AE1",
  46.  "AW2","UH2","UH1","UH" ,"O2" ,"O1" ,"IU" ,"U1",
  47.  "THV","TH" ,"ER" ,"EH" ,"E1" ,"AW" ,"PA1","STOP",
  48.  0
  49. };
  50.  
  51. static const char *GorfWordTable[] =
  52. {
  53.  "A2AYY1","A2E1","UH1GEH1I3N","AE1EH2M","AEM",
  54.  "AE1EH3ND","UH1NAH2I1YLA2SHUH2N","AH2NUHTHER","AH1NUHTHVRR",
  55.  "AH1R","UHR","UH1VEH1EH3NNDJER","BAEEH3D","BAEEH1D","BE",
  56.  "BEH3EH1N","buht","BUH1DTTEH2NN","KUHDEH2T",
  57.  "KAE1NUH1T","KAE1EH3PTI3N",
  58.  "KRAH2UH3NI3KUH3O2LZ","KO1UH3I3E1N","KO1UH3I3E1NS",
  59.  "KERNAH2L","KAH1NCHEHSNEHS","DE1FEH1NDER",
  60.  "DE1STRO1I1Y","DE1STRO1I1Y1D",
  61.  "DU1UM","DRAW1S","EHMPAH2I3YR","EHND",
  62.  "EH1NEH1MY","EH1SKA1E1P","FLEHGSHIP",
  63.  "FOR","GUH1LAEKTI1K",
  64.  "DJEH2NERUH3L","GDTO1O1RRFF","GDTO1RFYA2N","GDTO1RFE1EH2N","GDTO1RFYA2NS",
  65.  "HAH1HAH1HAH1HAH1","hahaher.wav","HUHRDER",
  66.  "HAE1EH3V","HI1TI1NG","AH1I1Y", "AH1I1Y1","I1MPAH1SI1BL",
  67.  "IN*","INSERT","I1S","LI1V","LAWNG","MEE1T","MUU1V",
  68.  "MAH2I1Y","MAH2I3Y","NIR","NEHKST","NUH3AH2YS","NO",
  69.  "NAH1O1U1W","PA1","PLA1AYER","PRE1PAE1ER","PRI1SI3NEH3RS",
  70.  "PRUH2MOTEH3D","POO1IUSH","RO1U1BAH1T","RO1U1BAH1TS",
  71.  "RO1U1BAH1UH3TS","SEK", "SHIP","SHAH1UH3T","SUHM","SPA2I3YS","PA0",
  72.  "SERVAH2I1Y1VUH3L","TAK","THVUH","THVUH1",
  73.  "THUH","TAH1EH3YM","TU","TIUU1",
  74.  "UH2NBE1AYTUH3BUH3L",
  75.  "WORAYY1EH3R","WORAYY1EH3RS","WI1L",
  76.  "Y1I3U1","YIUU1U1","YI1U1U1","Y1IUU1U1","Y1I1U1U1","YOR","YU1O1RSEH1LF","s.wav",
  77.  "FO1R","FO2R","WIL","GDTO1RVYA2N",
  78.  
  79.  "KO1UH3I3AYNN",
  80.  "UH1TAEEH3K","BAH2I3Y1T","KAH1NKER","DYVAH1U1ER","DUHST","GAE1LUH1KSY","GAH1EH3T",
  81.  "PAH1I1R","TRAH2I1Y","SU1PRE1N","AWL","HA2AYL",
  82.  "EH1MPAH1I1R",
  83. 0
  84. };
  85.  
  86. #define num_samples (sizeof(GorfWordTable)/sizeof(char *))
  87.  
  88. static const char *gorf_sample_names[] =
  89. {
  90.  "*gorf","a.wav","a.wav","again.wav","am.wav","am.wav","and.wav","anhilatn.wav",
  91.  "another.wav","another.wav","are.wav","are.wav",
  92.  "avenger.wav","bad.wav","bad.wav","be.wav",
  93.  "been.wav","but.wav","button.wav","cadet.wav",
  94.  "cannot.wav","captain.wav","chronicl.wav","coin.wav","coins.wav","colonel.wav",
  95.  "consciou.wav","defender.wav","destroy.wav","destroyd.wav",
  96.  "doom.wav","draws.wav","empire.wav","end.wav",
  97.  "enemy.wav","escape.wav","flagship.wav","for.wav","galactic.wav",
  98.  "general.wav","gorf.wav","gorphian.wav","gorphian.wav","gorphins.wav",
  99.  "hahahahu.wav","hahaher.wav","harder.wav","have.wav",
  100.  "hitting.wav","i.wav","i.wav","impossib.wav","in.wav","insert.wav",
  101.  "is.wav","live.wav","long.wav","meet.wav","move.wav",
  102.  "my.wav","my.wav",
  103.  "near.wav","next.wav","nice.wav","no.wav",
  104.  "now.wav","pause.wav","player.wav","prepare.wav","prisonrs.wav",
  105.  "promoted.wav","push.wav","robot.wav","robots.wav","robots.wav",
  106.  "seek.wav","ship.wav","shot.wav","some.wav","space.wav","spause.wav",
  107.  "survival.wav","take.wav","the.wav","the.wav","the.wav","time.wav",
  108.  "to.wav","to.wav","unbeatab.wav",
  109.  "warrior.wav","warriors.wav","will.wav",
  110.  "you.wav","you.wav","you.wav","you.wav","your.wav","your.wav","yourself.wav",
  111.  "s.wav","for.wav","for.wav","will.wav","Gorph.wav",
  112. // Missing Samples
  113.  "coin.wav", "attack.wav","bite.wav","conquer.wav","devour.wav","dust.wav",
  114.  "galaxy.wav","got.wav","power.wav","try.wav","supreme.wav","all.wav",
  115.  "hail.wav","emperor.wav",
  116.  0
  117. } ;
  118.  
  119.  
  120. /* Total word to join the phonemes together - Global to make it easier to use */
  121. char totalword[256], *totalword_ptr;
  122. char oldword[256];
  123. int plural = 0;
  124.  
  125. int gorf_sh_start(const struct MachineSound *msound)
  126. {
  127.     Machine->samples = readsamples(gorf_sample_names,Machine->gamedrv->name);
  128.  
  129.     GorfBaseFrequency = 11025;
  130.     GorfBaseVolume = 230;
  131.     GorfChannel = 0;
  132.     return 0;
  133. }
  134.  
  135. READ_HANDLER( gorf_speech_r )
  136. {
  137.     int Phoneme,Intonation;
  138.     int i = 0;
  139.  
  140.     int data;
  141.  
  142.     totalword_ptr = totalword;
  143.  
  144.     data = cpu_get_reg(Z80_BC) >> 8;
  145.  
  146.     Phoneme = data & 0x3F;
  147.     Intonation = data >> 6;
  148.  
  149.     logerror("Date : %d Speech : %s at intonation %d\n",Phoneme, PhonemeTable[Phoneme],Intonation);
  150.  
  151.      if(Phoneme==63) {
  152.            sample_stop(GorfChannel);
  153.                 if (strlen(totalword)>2) logerror("Clearing sample %s\n",totalword);
  154.                 totalword[0] = 0;                   /* Clear the total word stack */
  155.                      return data;
  156.     }
  157.  
  158. /* Phoneme to word translation */
  159.  
  160.      if (strlen(totalword) == 0) {
  161.          strcpy(totalword,PhonemeTable[Phoneme]);                       /* Copy over the first phoneme */
  162.          if (plural != 0) {
  163.              logerror("found a possible plural at %d\n",plural-1);
  164.              if (!strcmp("S",totalword)) {           /* Plural check */
  165.                  sample_start(GorfChannel, num_samples-2, 0);       /* play the sample at position of word */
  166.                  sample_set_freq(GorfChannel, GorfBaseFrequency);    /* play at correct rate */
  167.                  totalword[0] = 0;                   /* Clear the total word stack */
  168.                  oldword[0] = 0;                   /* Clear the total word stack */
  169.                  return data;
  170.              } else {
  171.                  plural=0;
  172.              }
  173.          }
  174.      } else
  175.          strcat(totalword,PhonemeTable[Phoneme]);                       /* Copy over the first phoneme */
  176.  
  177.      logerror("Total word = %s\n",totalword);
  178.  
  179.      for (i=0; GorfWordTable[i]; i++) {
  180.          if (!strcmp(GorfWordTable[i],totalword)) {           /* Scan the word (sample) table for the complete word */
  181.              if ((!strcmp("GDTO1RFYA2N",totalword)) || (!strcmp("RO1U1BAH1T",totalword)) || (!strcmp("KO1UH3I3E1N",totalword)) || (!strcmp("WORAYY1EH3R",totalword)) || (!strcmp("IN",totalword)) ) {              /* May be plural */
  182.                  plural=i+1;
  183.                  strcpy(oldword,totalword);
  184.           logerror("Storing sample position %d and copying string %s\n",plural,oldword);
  185.              } else {
  186.              plural=0;
  187.           }
  188.           sample_start(GorfChannel, i, 0);                       /* play the sample at position of word */
  189.           sample_set_freq(GorfChannel, GorfBaseFrequency);       /* play at correct rate */
  190.           logerror("Playing sample %d",i);
  191.           totalword[0] = 0;                   /* Clear the total word stack */
  192.           return data;
  193.        }
  194.     }
  195.  
  196.     /* Note : We should really also use volume in this as well as frequency */
  197.      return data;                                   /* Return nicely */
  198. }
  199.  
  200. int gorf_status_r(void)
  201. {
  202.     return !sample_playing(GorfChannel);
  203. }
  204.  
  205. /* Read from port 2 (0x12) returns speech status as 0x80 */
  206.  
  207. READ_HANDLER( gorf_port_2_r )
  208. {
  209.     int Ans;
  210.  
  211.     Ans = (input_port_2_r(0) & 0x7F);
  212.     if (gorf_status_r() != 0) Ans += 128;
  213.     return Ans;
  214. }
  215.  
  216. void gorf_sh_update(void)
  217. {
  218. }
  219.